define(['jquery', 'bootstrap', 'backend', 'table', 'form', 'editable'], function ($, undefined, Backend, Table, Form, undefined) {
    var Controller = {
        index: function () {
            // 初始化表格参数配置
            Table.api.init({
                extend: {
                    index_url: 'feedback/index' + location.search,
                    del_url: 'feedback/del',
                    edit_url: 'feedback/edit',
                    multi_url: 'feedback/multi',
                    table: 'yexam_subject',
                }
            });
            var table = $("#table");
            // 初始化表格
            table.bootstrapTable({
                url: $.fn.bootstrapTable.defaults.extend.index_url,
                escape: false,
                pk: 'id',
                sortName: 'id',
                sortOrder:'desc',
                columns: [
                    [
                        {checkbox: true},
                        {field: 'id', title: __('Id')},
                        {field: 'content', title: __('内容'),align: 'left',operate:'LIKE'},
                        {field: 'mobile', title: __('手机号'),align: 'left', operate: false},

                        {field: 'type', title: __('反馈类型'),align: 'left', operate: false,formatter: function (value) {
                            switch (value)
                            {
                                case 1:return "支付问题";
                                case 2:return "IOS版本问题";
                                case 3:return "功能使用";
                                case 4:return "其他";
                                case 5:return "建议";
                            }
                            }},
                        {field: 'reply', title: __('回复'),align: 'left',operate:'LIKE'},
                        {field: 'remark', title: "备注",operate: false},
                        {field: 'add_time', title: "反馈时间",operate: false,formatter: Table.api.formatter.datetime},
                        {field: 'operate', title: __('Operate'), table: table, events: Table.api.events.operate, formatter: Table.api.formatter.operate,}
                    ]
                ]
            });
            // 为表格绑定事件
            Table.api.bindevent(table);
        },
        add: function () {
            Controller.api.bindevent();
        },
        edit: function () {
            Controller.api.bindevent();
        },
        api: {
            formatter:{
                is_pay: function (value, row, index) {
                    return value?'是':'否';
                },
            },
            bindevent: function () {
                $("#c-package_ids").data("params", function (obj) {
                    return {custom: {category_id: $("#c-category_id").val()}};
                });
                Form.api.bindevent($("form[role=form]"));
            }
        },
    };
    return Controller;
});
